package com.suixun.controller;


import com.suixun.controller.base.BaseController;
import com.suixun.domain.CooperationPolicy;
import com.suixun.service.CooperationPolicyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 合作政策 前端控制器
 * </p>
 *
 * @author jacky
 * @since 2018-01-11
 */
@RestController
@RequestMapping("/cooperationPolicy")
public class CooperationPolicyController extends BaseController {

    @Resource
    private CooperationPolicyService cooperationPolicyService;

    @PostMapping("/add")
    public Object insert(CooperationPolicy cooperationPolicy, Boolean isTop) {
        cooperationPolicyService.insert(cooperationPolicy, isTop);
        return success();
    }

    @GetMapping("/page/{page}/{size}")
    public Object page(@PathVariable Integer page, @PathVariable Integer size, String title) {
        return success(cooperationPolicyService.pageExclusionContent(page, size, title, 1));
    }

    @GetMapping("/get/{id}")
    public Object get(@PathVariable Integer id) {
        return success(cooperationPolicyService.getById(id));
    }

    @PostMapping("/update")
    public Object update(CooperationPolicy cooperationPolicy, Boolean isTop) {
        cooperationPolicyService.update(cooperationPolicy, isTop);
        return success();
    }

    @PostMapping("/delete")
    public Object delete(String ids) {
        cooperationPolicyService.delete(ids);
        return success();
    }
}
